#ifndef __PICTUREPUZZLEGAMEAREA_H__
#define __PICTUREPUZZLEGAMEAREA_H__
 
#include "cocos2d.h"  
#include "..\cocos2d\extensions\cocos-ext.h"
#include "cocos\ui\CocosGUI.h"
#include "PuzzleGuess.h"
#include "PictureItemCell.h"
 

NS_GAME_BEGIN
	 

class PicturePuzzleGameArea : 
	public cocos2d::Node
{
protected:
	unsigned int columnCount;
	unsigned int rowCount;
	cocos2d::Size cellSize;
	cocos2d::Size cellScaleSize;
	cocos2d::extension::Scale9Sprite* pictureBorder;  
	cocos2d::LayerColor* puzzleLayer;
	unsigned int borderWidth;
	cocos2d::Size cellMoreSize;
	cocos2d::Image* imageSource;
	int gameAreaMarginTop;
	int gameAreaMarginRight;
	int gameAreaMarginBottom;
	int gameAreaMarginLeft;
	std::vector<PictureItemCell*> puzzleCells;
	PictureItemCell* movingPuzzleCell;
	int puzzleCellBottomZOrder;
	int puzzleCellTopZOrder;
	unsigned int currentPuzzleCellZOrder;
	bool isMovingPuzzleCell;
	PicturePuzzleGameArea();
	~PicturePuzzleGameArea();
	 
	void createPuzzleCellArray();
public:     
	void setGameAreaMargin(int _top, int _right, int _bottom, int _left);
	void setPuzzleImageSource(cocos2d::Image* _imageSource); 
	void resetChildrenPosition(); 
	void setContentSize(const cocos2d::Size& contentSize) override;
	// Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone
	virtual bool init();    
	// implement the "static create()" method manually
	CREATE_FUNC(PicturePuzzleGameArea);   
	  
	virtual bool onTouchBegan(cocos2d::Touch *touch, cocos2d::Event *event);

	virtual void onTouchMoved(cocos2d::Touch *touch, cocos2d::Event *event);

	virtual void onTouchEnded(cocos2d::Touch *touch, cocos2d::Event *event);

	virtual void onTouchCancelled(cocos2d::Touch *touch, cocos2d::Event *event);
	 
}; 
 
NS_GAME_END

#endif	//__PICTUREPUZZLEGAMEAREA_H__